<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>操作日志</title>
  <link rel="stylesheet" href="../../../layui/css/layui.css">
  <script src="../../../layui/layui.js"></script>
</head>
<style type="text/css">
  body{
    height: 100%;
    width: 100%;
    margin-top: 11px;
  }
  .xiugai {
    margin-left: -0.5px;
    margin-top: 10px;
  }

</style>

<body >
<!-- 内容主体区域 -->
<div class="layui-fluid layui-form">
  <div class="layui-form-item">
<!--    <div class="layui-input-inline " style=" width: 638px;">
      <button class="layui-btn layui-btn-primary addUser">新增用户</button>
&lt;!&ndash;      <button class="layui-btn">默认按钮</button>
      <button class="layui-btn layui-btn-normal">百搭按钮</button>&ndash;&gt;
     </div>-->
    <div class="layui-inline">
      <label class="layui-form-label">搜索选择框</label>
      <div class="layui-input-inline">
        <select name="modules"  lay-search="" class="userKey">
          <option value="">直接选择或搜索选择</option>
          <option value="user_code">用户账号</option>
          <option value="user_name">用户名称</option>
          <option value="email">email</option>
        </select>
      </div>
    </div>
    <div class="layui-inline">
      <div class="layui-input-inline">
        <input type="text" name="userKey" class="layui-input userKeyValue ">
      </div>
      <div class="layui-input-inline">
        <button class="layui-btn layuiadmin-btn-admin layui-btn-normal check" lay-submit="" lay-filter="LAY-user-back-search">
          <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
        </button></div>
    </div>
  </div>
</div>

<div id="pTable" >
  <table id="layui_table_id" class="layui-table" lay-skin="line" lay-filter="test" style="width: 1680px">

  </table>
<!--  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script>-->
  <div id="laypage"></div>
</div>
</body>
</html>

<script type="text/javascript">
  layui.use(['form','laydate','layer','table','laypage','util'],function(){
    var form = layui.form;
    var laydate=layui.laydate;
    var $ = layui.$;
    productsearch(1);

    function productsearch(page,filterExpr) {

      var table = layui.table,
      laydate = layui.laydate,
      laypage = layui.laypage;
      var form = layui.form;
      table.render({
        elem : '#layui_table_id',
        url : '/hy/basic/operateLog/getOperateLog',
        cols : [ [
              {checkbox: true,
                filter:'test'
              }
              ,
              {
                field : 'optUser',
                title : '操作用户',
                sort : true,
                align : 'center'
              },
              {
                field : 'optRole',
                title : '操作角色',
                sort : true,
                align : 'center'
              }
              , {
                field : 'optAction',
                title : '操作动作',
                align : 'center'
              }
              , {
                field : 'optDate',
                title : '操作日期',
                align : 'center',
              }
              , {
                field : 'optInfo',
                title : '操作信息',
                align : 'center'
              }
              , {
                field : 'optUrl',
                title : '操作请求地址',
                align : 'center'
              }
              , {
                field : 'optResult',
                title : '操作返回结果',
                align : 'center'
              }


        ] ],
        page : true,
        where : {
          filterExpr:filterExpr,
        },
        responseHandler: function (res, curr,count) {
          $('#pageNum').val(curr);
          return {
            "count": res.total,
            "data": res.data,
            "code": 0,//code值为200表示成功
            "msg": ""
          }
        },
        done : function(res, curr, count) {
          console.log(res)
          $('#pageNum').val(curr);

        }
      })
      // table.on('checkbox(test)', function(obj){
      //   console.log(layui.table.checkStatus('layui_table_id'));
      // });
     // 监听工具条
      table.on('tool(test)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
        if (layEvent == 'detail') {
          queryById(data.id);
        } else if (layEvent == 'del') {
          //alert(data.id)
          var pageNum = $('#pageNum').val();
          layer.confirm('真的删除行么', function(index){
            deleteById(data.id);
            layer.close(index);
            //向服务端发送删除指令
          });
        } else if (layEvent === 'edit') {
          layer.msg('编辑操作');
        }
      });
      //常规用法
      laydate.render({
        elem : '#createDate'
      });
      //常规用法
      laydate.render({
        elem : '#processingTime'
      });

    }

    $(".check").on("click", function() {

      var userKey=$('.userKey option:selected').val();
      if(userKey!=""){
        var userKeyValue = $('.userKeyValue').val();
        var temp = userKey+"='"+userKeyValue+"'";
        productsearch(1, temp);
      }else{
        productsearch(1);
      }

    })


  });
  function userStatus(t){
     if(t==0){
       return '启用';
     }else{
       return '禁用';
     }
    return util.toDateString(t1);
  }
</script>


<script type="text/html" id="userStatus">


        {{ userStatus(d.userStatus) }}
</script>